@extends('layouts.back_stage')
@section('style')
    @parent
    <link rel="stylesheet" href="{{env('CDN_DOMAIN_NAME')}}/css/commoncss/jquery.dataTables.min.css"/>
    <link href="{{env('CDN_DOMAIN_NAME')}}/css/daterangepicker-bs3.css" rel="stylesheet">
@endsection
@section('script')
    @parent
    <script src="{{env('CDN_DOMAIN_NAME')}}/js/commonjs/jquery.dataTables.min.js"></script>
    <script src="{{ env('CDN_DOMAIN_NAME') }}/js/moment.js" type="text/javascript"></script>
    <script src="{{ env('CDN_DOMAIN_NAME') }}/js/daterangepicker.js" type="text/javascript"></script>
@endsection
@section('content')
    <style>
        .address {
            border-color: #cfdadd;
            border-radius: 2px;
            width: 25%;
            height: 30px;
            padding: 6px 10px;
            font-size: 12px;
            line-height: 1.42857143;
            color: #555;
            background-color: #fff;
            background-image: none;
            border: 1px solid #cfdadd;
            box-shadow: none;
            -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
            -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
        }
        table.dataTable thead .sorting:after,table.dataTable thead .sorting_desc:after{content: "";}
        table,th,td{text-align: center}
    </style>
    <div class="container">
        <div style="padding:20px 0;"><h3>客户购买及操作信息</h3></div>
        <div class="pull-left" style="width: 100%;margin-bottom: 20px">
            <form action="/finance/userRanking" role="form" style="display: inline-block;margin-right: 10px">
{{--            @if($self_company_id == 1)--}}
                <label>选择公司：</label>
                <select name="company_id" id="sort" class="address company_id" style="width: 150px">
                    <option value="">全部公司</option>
                    @foreach($companys as $k => $v)
                        <option value="{{$k}}"
                                @if(isset($_GET['company_id']) && $_GET['company_id']==$k)
                                selected
                                @else
                                @endif > {{$v}}
                        </option>
                    @endforeach
                </select>
                <label>日期:</label>
<!--                --><?php // dump($req->begin_end_time); ?>
                <input type="text" readonly style="width:180px;height:30px;" name="begin_end_time" id="reservation" class="address time1_time2" autocomplete="off" value="{{$req->begin_end_time}}" placeholder="选择起止时间" />
                {{--@else--}}
                    {{--<input type="hidden" name="company_id" value="{{ $self_company_id }}">--}}
                {{--@endif--}}
                <label>用户姓名:</label>
                <input class="address user_name" style="width: 150px" type="text" name="user_name" placeholder="输入用户姓名"
                       value="<?php echo  isset($_GET['user_name'])?$_GET['user_name']:'' ?>">
                <label>手机号码:</label>
                <input class="address user_tel" style="width: 150px" type="text" name="user_tel" placeholder="手机号码" value="<?php echo  isset($_GET['user_tel'])?$_GET['user_tel']:'' ?>">
                <button type="submit" class="btn btn-info" id="sort_btn" style="margin-bottom:4px;">搜索</button>

            </form>
            <a href="javascript:;" class="btn btn-primary" style="float: right;margin-right:30px;" onclick="Export();">导出</a>
        </div>
        <table class="table table-hover data-table">
            <thead>
                <tr>
                    <th class="nosort">用户姓名</th>
                    <th class="nosort">手机号</th>
                    <th class="nosort">所属公司</th>
                    <th>交易笔数</th>
                    {{--<th>总金额(含邮费和退款)</th>--}}
                    {{--<th>成功支付金额</th>--}}
                    <th>控款次数</th>
                    <th>有效订单数</th>
                    <th>退单次数</th>
                    {{--<th>登录次数</th>--}}
                    <th>邮费总计</th>
                    <th class="nosort">操作</th>
                </tr>
            </thead>
            <tbody>
            @if(count($order_infos)>0 )
                @foreach($order_infos as $k => $v)
                <tr >
                    <td>{{$v['username'] }}</td>
                    <td>{{$v['user_tel']}}</td>
                    <td>{{$companys[$v['company_id']] or ''}}</td>
                    <td>{{$v['pay_nums']  or 0}}</td>
{{--                    <td>{{ sprintf("%.2f", $v['pay_price)}}</td>--}}
                    {{--                    <td>{{ sprintf("%.2f", $v['actual_pay_price)}}</td>--}}
                    <td>{{$v['participate_num'] or 0}}</td>
                    <td>{{$v['actual_pay_nums']  or 0}}</td>
                    <td>{{$v['return_nums']  or 0}}</td>
{{--                    <td>{{$v['nums}}</td>--}}
                    <td>{{$v['all_postage_estimate']  or 0}}</td>
                    <td>
                        <a href="/order/getHistoryOrderByUser?id={{$v['user_id']}}">详情</a>
                    </td>
                </tr>
                @endforeach
            @endif
            </tbody>
        </table>

        <div style="float: right">
            @if(count($user_infos)>0 )
                {{$order_infos->appends(['company_id'=>$req->company_id,'user_name'=>$req->user_name,'user_tel'=>$req->user_tel,'begin_end_time'=>$req->begin_end_time])->links()}}
            @endif
        </div>

    </div>
    <script>
        $('#reservation').daterangepicker(null, function(start, end, label) {
            console.log(start.toISOString(), end.toISOString(), label);
        });
        /*导出*/
        function Export()
        {
            var company_id = $(".company_id").val();
            var time1_time2 = $(".time1_time2").val();
            var user_name = $(".user_name").val();
            var user_tel = $(".user_tel").val();
            window.location.href = "/excel/userRankingExport?company_id=" + company_id +
                                    "&time1_time2=" + time1_time2 + "&user_name=" + user_name
                                    + "&user_tel=" + user_tel;
        }
        {{--var lang = {--}}
            {{--"sProcessing": "处理中...",--}}
            {{--"sLengthMenu": "每页 _MENU_ 项",--}}
            {{--"sZeroRecords": "没有匹配结果",--}}
            {{--"sInfo": "当前显示第 _START_ 至 _END_ 项，共 _TOTAL_ 项。",--}}
            {{--"sInfoEmpty": "当前显示第 0 至 0 项，共 0 项",--}}
            {{--"sInfoFiltered": "(由 _MAX_ 项结果过滤)",--}}
            {{--"sInfoPostFix": "",--}}
            {{--"sSearch": "搜索:",--}}
            {{--"sUrl": "",--}}
            {{--"sEmptyTable": "表中数据为空",--}}
            {{--"sLoadingRecords": "载入中...",--}}
            {{--"sInfoThousands": ",",--}}
            {{--"oPaginate": {--}}
                {{--"sFirst": "首页",--}}
                {{--"sPrevious": "上页",--}}
                {{--"sNext": "下页",--}}
                {{--"sLast": "末页",--}}
                {{--"sJump": "跳转"--}}
            {{--},--}}
            {{--"oAria": {--}}
                {{--"sSortAscending": ": 以升序排列此列",--}}
                {{--"sSortDescending": ": 以降序排列此列"--}}
            {{--}--}}
        {{--};--}}
        {{--$('.data-table').dataTable({--}}
            {{--"language":lang,  //提示信息--}}
            {{--"searching": false,  //是否允许Datatables开启本地搜索--}}
            {{--"paging": true,  //是否开启本地分页--}}
            {{--"lengthChange": false,  //是否允许用户改变表格每页显示的记录数--}}
            {{--"iDisplayLength" : 15,// 每页显示行数--}}
            {{--"info": false,   //控制是否显示表格左下角的信息--}}
            {{--"sPaginationType" : "full_numbers", // 分页，一共两种样式 另一种为two_button // 是datatables默认--}}
            {{--"columnDefs": [{--}}
                {{--"targets": 'nosort',  //列的样式名--}}
                {{--"orderable": false    //包含上样式名‘nosort’的禁止排序--}}
            {{--}],--}}
            {{--//跟数组下标一样，第一列从0开始，这里表格初始化时，第四列默认降序--}}
            {{--"order": [3]  //asc升序   desc降序  "order": [[ 3, "desc" ]]默认第四列为降序排列--}}
        {{--});--}}
    </script>
@endsection